# 原文件bill.txt,只保留“正式”的文件内容，并另存一个文件bill.txt.bak
#! /usr/bin/env python
with open('bill.txt','r',encoding='utf-8') as fr, open('bill.txt.bak','w',encoding='utf-8') as fw:
    for i in fr:
        i = i.strip()   #去除开头和结尾的空格以及换行符
        if i.split(',')[4] == '测试':
            continue
        fw.write(i)
        fw.write('\n')